var Looper = {
	currentAnimation : 0,
	animations : [ ],
    loopFinishCallback : null,
	
}

Looper.init = function(){

}

Looper.parseItem = function(item){
				var itemType = item.attributes.getNamedItem("type").nodeValue;
				
				//alert("itemType: "+ itemType);
				
				var itemTime = item.attributes.getNamedItem("time").nodeValue;
				
				//alert("itemTime: "+ itemTime);
				
				var itemText = item.childNodes[0].nodeValue;
				
				//alert("itemText: "+ itemText);
				
                if (itemType && itemTime && itemText){
					// TODO: insert animation here
					alert(itemType + " " + itemTime + " " + itemText + "\n");
                }

}

Looper.scrollingTextAnimation = function(text,loops){
			
			$(".scrollingtext").text(text);
			
			$('#banner').SetScroller({	velocity: 	 90,
											direction: 	 'horizontal',
											startfrom: 	 'right',
											loop:		 loops,
											movetype: 	 'linear',
											onstartup: 	 'play',
											cursor: 	 'pointer',
											oncomplete:  function(){ 
																	$('#banner').hide(); 
																	_gaq.push(['_trackEvent', 'Animation', 'Scroll', text + " " + loops]); 
																	Looper.onAnimationComplete(); }
											}).show();

}

Looper.blankAnimation = function(delay){
	setTimeout(
        function() {
			_gaq.push(['_trackEvent', 'Animation', 'Blank', delay]); 
			Looper.onAnimationComplete();
        },
        delay * 1000 // delay in sec
    );
}

Looper.onAnimationComplete = function(){
	alert("onAnimationComplete");
	
	//TODO: Implement going to next animation
	
	if(allAnimationsFinished){
		this.loopFinishCallback()
	}
}

